--
-- Licensed to the Apache Software Foundation (ASF) under one or more
-- contributor license agreements.  See the NOTICE file distributed with
-- this work for additional information regarding copyright ownership.
-- The ASF licenses this file to You under the Apache License, Version 2.0
-- (the "License"); you may not use this file except in compliance with
-- the License.  You may obtain a copy of the License at
--
--     http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--

-- for AT mode you must to init this sql for you business database. the seata server not need it.
CREATE TABLE [undo_log]
(
    [branch_id]     bigint                NOT NULL,
    [xid]           varchar(128)          NOT NULL,
    [context]       varchar(128)          NOT NULL,
    [rollback_info] varbinary(max)        NOT NULL,
    [log_status]    int                   NOT NULL,
    [log_created]   datetime2              NOT NULL,
    [log_modified]  datetime2              NOT NULL,
    CONSTRAINT [ux_undo_log] UNIQUE NONCLUSTERED ([xid], [branch_id])
        WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
)
GO

CREATE NONCLUSTERED INDEX [ix_log_created]
    ON [undo_log] (
                     [log_created]
        )
GO
